<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta content="IE=8" http-equiv="X-UA-Compatible" />
    <title>添加用户</title>
    {$QPath}
    <link rel="stylesheet" type="text/css" href="__TMPL__../Admin/Public/base.css" />
    <script type="text/javascript" src="__TMPL__../Admin/Public/mootools.js"></script>
    <script type="text/javascript">
        var _validate=[
            ['role',[
                    { rule:'required',msg:'请选择用户所属的角色'}
                ]
            ],
            ['account',[
                    { rule:'required',msg:'用户名必须填写'},
                    { rule:'^[a-zA-Z][a-zA-Z0-9_@-]{0,15}$',msg:'用户名只能包含字母、数字、"@"、"_"和"-"，且必须以字母开始'}
                ]
            ],
            ['password',[
                    { rule:'required',msg:'密码必须填写'},
                    { rule:'^.{6,}$',msg:'密码至少6个字符'}
                ]
            ],
            ['realname',[
                    { rule:'required',msg:'真实姓名必须填写'}
                ]
            ]
        ];
    </script>
    <script type="text/javascript" src="__TMPL__../Admin/Public/base.js"></script>
</head>
<body>
    <div id="container">
        <table class="tabmenu" cellspacing="0">
            <tbody>
                <tr>
                    <td class="wedge">&nbsp;</td>
                    <td class="wmenu"><a href="__URL__/index"><span>用户列表</span></a></td>
                    <td class="wmenu here">添加用户</td>
                    <td class="wmenu"><a href="__APP__/pRole/index"><span>角色列表</span></a></td>
                    <td class="wmenu"><a href="__APP__/pRole/add"><span>添加角色</span></a></td>
                    <td>&nbsp;</td>
                </tr>
            </tbody>
        </table>
        <div class="main">
            <ul class="fnc">
                <li><button type="button" class="btn primary" onclick="doSave()">保存</button></li>
            </ul>
            <form id="ipsForm" method="post" action="__URL__">
                <input type="hidden" name="a">
                <table class="ips">
                    <tbody>
                        <tr>
                            <th class="essential"><label for="pk1">所属角色：</label></th>
                            <td>
                                <select name="role" id="pk1">
                                    <option value="">请选择...</option>
                                    <iterate name="roles" id="vo">
                                    <option value="{$vo['id']}">{$vo['name']}</otpion>
                                    </iterate>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th class="essential"><label for="pk2">用户名：</label></th>
                            <td>
                                <input type="text" id="pk2" name="account" size="32" maxlength="16" />
                                <p class="hint">长度不能超过16个字符，只能包含字母、数字、"@"、"_"和"-"，且必须以字母开始</p>
                            </td>
                        </tr>
                        <tr>
                            <th class="essential"><label for="pk3">密码：</label></th>
                            <td>
                                <input type="password" id="pk3" name="password" size="32" maxlength="16" />
                                <p class="hint">至少6个字符</p>
                            </td>
                        </tr>
                        <tr>
                            <th class="essential"><label for="pk4">真实姓名：</label></th>
                            <td>
                                <input type="text" id="pk4" name="realname" size="40" maxlength="32" />
                                <p class="hint">长度不能超过32个字符</p>
                            </td>
                        </tr>
                        <tr>
                            <th><label for="pk5">邮箱：</label></th>
                            <td>
                                <input type="text" id="pk5" name="email" size="60" maxlength="64" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
            <ul class="fnc">
                <li><button type="button" class="btn primary" onclick="doSave()">保存</button></li>
            </ul>
        </div>
    </div>
    <script type="text/javascript">
        function doSave(){
            doAction('save',{
                    submitType:'ajax',
                    ajaxOptions:{
                        runningMsg:'正在保存用户信息，请等候',
                        successMsg:'成功创建了帐号为<b>'+$("pk2").getProperty('value')+'</b>的用户',
                        callback:function(result,json){
                            if(result=='success') window.location="__URL__/index";
                        }
                    }
                });
        }
    </script>
</body>
</html>
